const baseUrl = 'http://localhost:8080'
import {
		useUserStore
	} from '@/store/index';
	let useUserInfo = useUserStore()
//get请求
const get = (urlString,token='') => {
	const promise = new Promise((res, req) => {
		uni.request({
			url: baseUrl+urlString,
			header: {
				'content-type': 'application/json',
				 'Authorization': token
			},
			success(result) {
				res(result)
			},
			fail(err) {
				req(err)
			}
		})
	})
	return promise
}
//post请求
const post = (urlString, data,token='') => {
	const promise = new Promise((res, req) => {
		uni.request({
			url: baseUrl+urlString,
			data: data,
			method: "POST",
			header: {
				'content-type': 'application/json',
				 'Authorization': token
			},
			success(result) {
				res(result)
			},
			fail(err) {
				req(err)
			}
		})
	})
	return promise
}

//delete请求
const del = (urlString, token='') => {
	const promise = new Promise((res, req) => {
		uni.request({
			url: baseUrl+urlString,
			method: "DELETE",
			header: {
				'content-type': 'application/json',
				'Authorization': token
			},
			success(result) {
				res(result)
			},
			fail(err) {
				req(err)
			}
		})
	})
	return promise
}

export {get, post, del, baseUrl}